<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<head>
    <title>Sse测试文档</title>
</head>
<body>
<div>sse测试</div>
<div id="result"></div>
</body>
</html>
<script>
    var params = new URLSearchParams(window.location.search);
    var token = params.get("token");
    console.log("token: " + token);
    if (token !== '') {
        // var source = new EventSource('http://localhost:8080/sse/subscribe?id=yihuihui');
        var source = new EventSource('http://partner.vahua.com/halali/app/partner/sse/subscribe?token=' + token);
        // var source = new EventSource('http://127.0.0.1:9091/halali/app/partner/sse/subscribe?token=' + token);
        source.onmessage = function (event) {
            text = document.getElementById('result').innerText;
            text += '\n' + event.data;
            document.getElementById('result').innerText = text;
        };
        source.onopen = function (event) {
            text = document.getElementById('result').innerText;
            text += '\n 开启: ';
            console.log(event);
            document.getElementById('result').innerText = text;
        };
    }

</script>